<?php

/**
 * Portfolio form base class.
 *
 * @method Portfolio getObject() Returns the current form's model object
 *
 * @package    rrtk
 * @subpackage form
 * @author     irh
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasePortfolioForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'user_profile_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('UserProfile'), 'add_empty' => false)),
      'title'           => new sfWidgetFormInputText(),
      'about'           => new sfWidgetFormTextarea(),
      'title_image_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TitleImage'), 'add_empty' => true)),
      'main_image_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('MainImage'), 'add_empty' => true)),
      'slug'            => new sfWidgetFormInputText(),
      'solution_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Solution'), 'add_empty' => true)),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'user_profile_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('UserProfile'))),
      'title'           => new sfValidatorString(array('max_length' => 255)),
      'about'           => new sfValidatorString(array('max_length' => 1000)),
      'title_image_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TitleImage'), 'required' => false)),
      'main_image_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('MainImage'), 'required' => false)),
      'slug'            => new sfValidatorString(array('max_length' => 255)),
      'solution_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Solution'), 'required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('portfolio[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Portfolio';
  }

}
